package practise;

public class InvertTree {
    public TreeNode invertTree(TreeNode root) {
        if(root == null) {
            return null;
        }
        if(root.left != null) {
            invertTree(root.left);
        }
        if(root.right != null) {
            invertTree(root.right);
        }
        TreeNode tree = root.left;
        root.left = root.right;
        root.right = tree;
        return root;
    }
}
